<template>
  <div class="mod-marketing-distribution">
    <el-tabs
      v-model="tabValue"
      @tab-click="tabClick"
    >
      <el-tab-pane
        :label="$t('shop.setUpShop')"
        name="shop"
      >
        <shop
          ref="shopRef"
          :tab-value="tabValue"
        />
      </el-tab-pane>
      <el-tab-pane
        v-if="paySettlementType!==1"
        :label="$t('shop.applicationForStoreOpening')"
        name="management"
      >
        <management
          ref="managementRef"
          :tab-value="tabValue"
        />
      </el-tab-pane>
      <el-tab-pane
        v-if="paySettlementType!==1 && signCategoryAuditSwitch && isAuth('shop:sign:page')"
        :label="$t('shop.contractApplication')"
      >
        <signManagement ref="signManagementRef" />
      </el-tab-pane>
      <!-- 移驾到企业管理 -->
      <!-- <el-tab-pane
        v-if="paySettlementType!==1"
        :label="$t('shop.changeBusinessInfor')"
      >
        <businessInformationApplication
          ref="businessInformationApplicationRef"
          :tab-value="tabValue"
        />
      </el-tab-pane> -->
    </el-tabs>
  </div>
</template>

<script setup>
import shop from './components/basic/index.vue'
import management from './components/account-management/index.vue'
import businessInformationApplication from './components/business-information-application/index.vue'
import signManagement from './components/sign-management/index.vue'
import { isAuth } from '@/utils'

const allinpayStore = useAllinpayStore()
const paySettlementType = computed(() => {
  return allinpayStore.paySettlementType
})

const tabValue = ref('shop')
const shopRef = ref(null)
const managementRef = ref(null)
const signManagementRef = ref(null)
onActivated(() => {
  if (tabValue === 'shop') {
    shopRef.value?.getDataList()
  } else {
    managementRef.value?.init()
    signManagementRef.value?.init()
  }
})

const tabClick = () => {
  if (tabValue === 'shop') {
    shopRef.value?.getDataList()
  }
}

onMounted(() => {
  onGetSignSwitch()
})
// 获取签约类目审核开关
const signCategoryAuditSwitch = ref(false) // 是否开启签约类目审核
const onGetSignSwitch = () => {
  // 签约类目
  http({
    url: http.adornUrl('/sys/audit/signingConfig'),
    method: 'get',
    params: http.adornParams()
  }).then(({ data }) => {
    if (data) {
      signCategoryAuditSwitch.value = JSON.parse(data).signingAudit
    }
  })
}

</script>

<style lang="scss" scoped>
div {
  :deep(.el-col-md-6){
    width:30%
  }
}
</style>
